/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.jr2tecnologia.model.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author ronildo
 */
@Entity
@Table(name = "page")
@NamedQueries({
    @NamedQuery(name = "Page.findAll", query = "SELECT p FROM Page p"),
    @NamedQuery(name = "Page.findByPkPage", query = "SELECT p FROM Page p WHERE p.pkPage = :pkPage"),
    @NamedQuery(name = "Page.findByName", query = "SELECT p FROM Page p WHERE p.name = :name"),
    @NamedQuery(name = "Page.findByLink", query = "SELECT p FROM Page p WHERE p.link = :link"),
    @NamedQuery(name = "Page.findByDescription", query = "SELECT p FROM Page p WHERE p.description = :description")})
public class Page implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "pk_page")
    private Long pkPage;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "link")
    private String link;
    @Column(name = "description")
    private String description;
    @JoinTable(name = "role_x_page", joinColumns = {
        @JoinColumn(name = "fk_page", referencedColumnName = "pk_page")}, inverseJoinColumns = {
        @JoinColumn(name = "fk_role", referencedColumnName = "pk_role")})
    @ManyToMany
    private List<Role> roleList;

    public Page() {
    }

    public Page(Long pkPage) {
        this.pkPage = pkPage;
    }

    public Page(Long pkPage, String name, String link) {
        this.pkPage = pkPage;
        this.name = name;
        this.link = link;
    }

    public Long getPkPage() {
        return pkPage;
    }

    public void setPkPage(Long pkPage) {
        this.pkPage = pkPage;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pkPage != null ? pkPage.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Page)) {
            return false;
        }
        Page other = (Page) object;
        if ((this.pkPage == null && other.pkPage != null) || (this.pkPage != null && !this.pkPage.equals(other.pkPage))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.jr2tecnologia.model.entity.Page[pkPage=" + pkPage + "]";
    }

}
